#ifndef TEXTBOX_H
#define TEXTBOX_H

#include <string>
#include <osgText/Text>
#include <osg/Geode>

using std::string;

class TextBox {
public:
  TextBox() : text(new osgText::Text()), 
	  textString("Dein Text"), 
	  textGeode(new osg::Geode()), 
	  stateSetGeode(new osg::StateSet())
  {
	text->setText(textString);
	// settzen das der Text immer zum Betrachter Zeigt
	text->setAxisAlignment(osgText::Text::SCREEN);

	stateSetGeode->setRenderBinDetails(11, "RenderBin");
	// Says this geometry should blend with any geometry behind it if any
	// transparency is specified.
	stateSetGeode->setMode(GL_BLEND, osg::StateAttribute::ON);
	// Set the Geometry to be top level, above all other geometry in the scene.
	// This actually makes the HUD visible
	stateSetGeode->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
	//Does what? I'm not sure... obviously something to do with transparency.
	stateSetGeode->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );

	textGeode->setStateSet(stateSetGeode.get());
	textGeode->addDrawable(text);
  }

	~TextBox () { }

	void setText(const string& text);
	void setFont(const string& font) { text->setFont(font); }
	void setColor(osg::Vec4d color) { text->setColor(color); }
	void setPosition(osg::Vec3d position) { text->setPosition(position);}
	void setTextSize(unsigned int size) { text->setCharacterSize(size); }
    
	osgText::Text& getTextObject() const { return *text; }
	const string& getText() const { return textString; }
	const osg::Vec4& getColor() const { return text->getColor(); }
	osg::Geode* getGeode(){ return textGeode.get(); }
    
private:

	osgText::Text* text;
	string textString;

	osg::ref_ptr<osg::Geode> textGeode;
	osg::ref_ptr<osg::StateSet> stateSetGeode;
};

#endif
